/*
 * Copyright (C) 2008 - 2009 Trinity <http://www.trinitycore.org/>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */

/* ScriptData
SDName: razorscale
SDAuthor: MaXiMiUS
SD%Complete: 65
EndScriptData */

#include "ScriptedPch.h"
#include "ulduar.h"

//not in db
#define SAY_AGGRO                   -2000000
#define SAY_KILL                    -2000001
#define SAY_PHASE_2_TRANS           -2000002
#define SAY_PHASE_3_TRANS           -2000003
#define EMOTE_BREATH                -2000004

//de los3.diff
#define SEAFORIUM_BLAST             52408
#define GOSSIP_ITEM_1      "Activar los Arpones !!"
#define SAY_SLEEP1         "Activar los Arpones !!"
#define SAY_SLEEP2         "Tomar posiciones !"
#define EMOTE_HARPOON      "Harpoon Turret is ready for use!"

enum Spells
{
    SPELL_FLAMEBUFFET      = 64016,
    SPELL_FIREBALL         = 62796,

    SPELL_WINGBUFFET       = 62666,
    SPELL_FLAMEBREATH      = 63317,
    SPELL_FUSEARMOR        = 64771,
    
	SPELL_DEVOURINGFLAME   = 63236, // Este es el que castea razorscale
	SPELL_DEVOURINGFLAME2  = 64709, // Este es el que castea el npc DevouringFlame 
	SPELL_CORRENTE         = 62505,
	SPELL_FOGO             = 62696,
	SPELL_STUN             = 9032
};

//de los3.diff
const Position Harpoon1 = { 590.442322, -130.550278, 391.516998};
const Position Harpoon2 = { 574.850159, -133.687439, 391.517151};
const Position posto1 = {614.975403, -155.138214, 391.517090, 0.625956};
const Position posto2 = {609.814331, -204.968185, 391.517090, 5.385465};
const Position posto3 = {563.530884, -201.557312, 391.517090, 4.108194};
const Position posto4 = {542.041260, -152.459198, 391.517090, 2.628720};
const Position RazorscaleV = {588.050293, -251.191223, 499.535980, 1.605303};
const Position RazorscaleV2 ={588.077881, -190.950729, 434.795807};
const Position RazorscaleC = {582.101135, -175.312286, 391.516998, 1.691704};
const Position controlerp = {581.461, -139.302, 391.516, 1.691704};
const Position WATCHER1 = {629.309, -197.959, 391.516, 1.691704};
const Position WATCHER2 = {561.045, -214.221, 391.516, 1.691704};
const Position WATCHER3 = {541.707, -166.307, 391.516, 1.691704};

enum Mobs
{
   NPC_DARK_RUNE_SENTINEL = 33846,
   //de los3.diff
   NPC_DARK_RUNE_GUARDIAN = 33388
};

struct boss_razorscaleAI : public BossAI {
	boss_razorscaleAI(Creature *pCreature) : BossAI(pCreature, TYPE_RAZORSCALE) {
		//De los3.diff
		m_pInstance = pCreature->GetInstanceData();
	}
	//De los3.diff
	ScriptedInstance* m_pInstance;

	uint8 Phase;
	
	uint32 FlameBreathTimer;
    uint32 FuseArmorTimer;
    uint32 DevouringFlameTimer;
    uint32 FlameBuffetTimer;
    uint32 SummonAddsTimer;
    uint32 WingBuffetTimer;
    uint32 FireballTimer;
	uint32 StunTimer;

    //uint32 CastSpellsTimer;

	//de los3.diff
	uint32 Summonwatcher;
	uint32 molemachine;
	uint32  flag;
	uint32  flag2;
	uint32  Chao;
	uint32  Voa;
	uint32  fogo;
	Creature* Harpoon[2];
	Creature* Chamas;

    bool InitialSpawn;
    bool IsFlying;
	bool IsPh2Ground;
	bool StunNeeded;


    void Reset() {
		_Reset();
        Phase = 0;

 		Chao = 999000;
		Voa = 999000;
		fogo = 50000;
	        
		FlameBreathTimer = 20000;
		DevouringFlameTimer = 2000;
		FuseArmorTimer = 15000;
		FlameBuffetTimer = 3000;
		SummonAddsTimer = 45000;
		WingBuffetTimer = 17000;
		StunTimer = 22000;
		
		InitialSpawn = true;
		IsPh2Ground = false;
		StunNeeded = false;

		///m_creature->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_TAUNT, true);
		///m_creature->ApplySpellImmune(1, IMMUNITY_EFFECT,SPELL_EFFECT_ATTACK_ME, true);

		//De los3.diff
		FireballTimer = 5000;
		Summonwatcher = 30000;
		molemachine = 4000;
		flag = 0;
		flag2 = 3;
		
		m_creature->SetSpeed(MOVE_FLIGHT, 5.0f);
		m_creature->GetMotionMaster()->MovePoint(0, RazorscaleV2);
		m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE);
		m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);

		SetCombatMovement(false);

		m_creature->SetFlying(true);

	}

	void MovementInform(uint32 uiType, uint32 uiPointId) {

		
		//Al spawnear, lo primero que hace es ir a un punto de media altura e intentar iniciar el combate
		if (uiType == 8 && uiPointId == 0 && InitialSpawn) {
			
			InitialSpawn = false;
			//m_creature->SelectVictim();

			Map *map = m_creature->GetMap();
            if (map->IsRaid()) {
                Map::PlayerList const &PlayerList = map->GetPlayers();
                if (PlayerList.isEmpty()) return;

				for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) {
					if (i->getSource()->isAlive()) {
						m_creature->SetInFront(i->getSource());
						AttackStartNoMove(i->getSource());
						break;
					}
				}
			}		
		}
		// En las fases de suelo de fase 2
		if (uiType == 8 && uiPointId == 0 && IsPh2Ground) {
			m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
			m_creature->SetFlying(false);
			m_creature->CastSpell(m_creature ,SPELL_STUN, true);
			StunNeeded = true;
		}
	}
	
    void EnterCombat(Unit* who) {
        ///DoScriptText(SAY_AGGRO, m_creature);
		_EnterCombat();
      
		 //De los3.diff
		Harpoon[0] = m_creature->SummonCreature(NPC_FIRE_STATE, 589.922974, -133.621994, 391.517090, 4.789456, TEMPSUMMON_CORPSE_DESPAWN, 999999);
		Harpoon[1] = m_creature->SummonCreature(NPC_FIRE_STATE, 571.947021, -136.011993, 391.516998, 4.789456, TEMPSUMMON_CORPSE_DESPAWN, 999999);
		Harpoon[0]->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE);
		Harpoon[1]->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE);
		Phase = 1;
		flag2 = 3;
		IsFlying = true;
		m_pInstance->SetData(TYPE_RAZORSCALE, IN_PROGRESS);
		m_creature->SetSpeed(MOVE_RUN, 5.0f);

		DoZoneInCombat();
   }

    void JustDied(Unit* Killer) {
		_JustDied();
    }

    void KilledUnit(Unit *victim) {
        DoScriptText(SAY_KILL, m_creature);
    }

    void UpdateAI(const uint32 diff) {
		if (!UpdateVictim())
			return;
     
		if ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) > 50) {
		
			if (StunNeeded && StunTimer <= diff) {
				m_creature->CastSpell(m_creature ,SPELL_STUN, true);
				StunTimer = 30000;
			} else StunTimer -= diff;

			if (fogo<=diff) {
				Chamas = m_creature->SummonCreature(33282, 580.465637, -135.182404, 391.516998, 0, TEMPSUMMON_CORPSE_DESPAWN, 999999);
				m_creature->SetInFront(Chamas);
				DoCast(Chamas, SPELL_WINGBUFFET);
				m_creature->SetInFront(Chamas);
				m_creature->CastSpell(Chamas, SPELL_FLAMEBREATH, true);
				Harpoon[0]->CastSpell(Harpoon[0], SPELL_FOGO, true);
				Harpoon[1]->CastSpell(Harpoon[1], SPELL_FOGO, true);
				m_creature->Kill(Chamas, false);
				fogo = 999000;
				Voa = 7000;
			} else fogo-= diff;
			if (Voa <= diff) {
				m_creature->SetSpeed(MOVE_RUN, 2.0f);
				m_creature->SetSpeed(MOVE_FLIGHT, 2.0f);
				m_creature->SetFlying(true);
				StunNeeded = false;
				m_creature->GetMotionMaster()->MovePoint(0,RazorscaleV2);
				m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
				Chao = 50000;
				Voa = 999000;
				Phase =1;
				IsPh2Ground = false;
			} else Voa-= diff;
			if (Chao<=diff) {
				m_creature->MonsterTextEmote(EMOTE_HARPOON, 0, true);
				Harpoon[0]->SetVisibility(VISIBILITY_ON);
				Harpoon[1]->SetVisibility(VISIBILITY_ON);
				Harpoon[0]->CastSpell(m_creature, SPELL_CORRENTE, true);
				Harpoon[1]->CastSpell(m_creature, SPELL_CORRENTE, true);
				m_creature->SetSpeed(MOVE_RUN, 2.0f);
				m_creature->SetSpeed(MOVE_FLIGHT, 2.0f);
				m_creature->SetFlying(true);
				IsPh2Ground = true;
				m_creature->GetMotionMaster()->MovePoint(0, RazorscaleC);
				Chao = 999000;
				fogo = 45000;
				Phase = 2;
				
			} else Chao-= diff;
		} else {
			Phase =3;
		}
		if (Summonwatcher<= diff) {
			m_creature->SummonCreature(NPC_DARK_RUNE_GUARDIAN, WATCHER1, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 10000);
			m_creature->SummonCreature(NPC_DARK_RUNE_GUARDIAN, WATCHER2, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 10000);
			m_creature->SummonCreature(NPC_DARK_RUNE_GUARDIAN, WATCHER3, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 10000);
			m_pInstance->SetData(TYPE_RAZORSCALE, DONE);
			Summonwatcher = 60000;
		 } else Summonwatcher -= diff;

		if (molemachine<= diff) {
			Summonwatcher = 6000;
			molemachine = 30000;
			m_pInstance->SetData(TYPE_RAZORSCALE, IN_PROGRESS);
		}else molemachine -= diff;

		//**********************************

		// Ground Phase (Phase 3 = permanent ground phase)
		if (Phase >= 2) {

        
			if (FuseArmorTimer <= diff) {
                DoCastVictim(SPELL_FUSEARMOR);
                FuseArmorTimer = 10000;
            } else FuseArmorTimer -= diff;

            if (WingBuffetTimer <= diff) {
                DoCast(SPELL_WINGBUFFET);
                WingBuffetTimer = urand(7000,14000);
            } else WingBuffetTimer -= diff;

            if (FireballTimer <= diff) {
                if (Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 50000.0, true)) {
                    m_creature->SetInFront(pTarget);
                    DoCast(pTarget, SPELL_FIREBALL);
                }

                ///FireballTimer = 18000;
				// de los3.diff
				FireballTimer = 5000;
            } else FireballTimer -= diff;

            if (FlameBreathTimer <= diff) {
                ///DoScriptText(EMOTE_BREATH, m_creature); // TODO: "Razorscale takes a deep breath..."
                DoCastVictim(SPELL_FLAMEBREATH);
                FlameBreathTimer = 15000;
                WingBuffetTimer = 0;
            } else FlameBreathTimer -= diff;

            if (Phase == 3) {
            

				//de los3.diff
				m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE);
				m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
				m_creature->SetFlying(false);

                if (FlameBuffetTimer <= diff) {
                    ///DoScriptText(EMOTE_BREATH, m_creature);
                    std::list<Unit*> pTargets;
                    SelectTargetList(pTargets, RAID_MODE(3,9), SELECT_TARGET_RANDOM, 50000.0, true);
                    uint8 i = 0;
                    for (std::list<Unit*>::iterator itr = pTargets.begin(); itr != pTargets.end();) {
                        if (m_creature->HasInArc(M_PI, *itr)) {
                            DoCast(*itr, SPELL_FLAMEBUFFET, true);
                            i++;
                        }
                        if (++itr == pTargets.end() || i == RAID_MODE(3,9)) {
                            AttackStart(*--itr); // seems to attack targets randomly during perma-ground phase..
                            break;
                        }
                    }
                    FlameBuffetTimer = 25000;
                } else FlameBuffetTimer -= diff;
            }

            DoMeleeAttackIfReady();
        }
		//Flying Phase
        if (Phase == 1) {

			/*Quitado por los3.diff
			if (InitialSpawn)
				SummonAdds();
            InitialSpawn = false;*/

            if (FireballTimer <= diff) {
                if (Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 50000.0, true)) {
                    m_creature->SetInFront(pTarget);
                    DoCast(pTarget, SPELL_FIREBALL);
                }
                
				FireballTimer = 5000;
            } else FireballTimer -= diff;

            if (DevouringFlameTimer <= diff) {
                if (Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 50000.0, true)) {
                    m_creature->SetInFront(pTarget);
                    m_creature->CastSpell(pTarget, SPELL_DEVOURINGFLAME,true);
                }
                DevouringFlameTimer = 10000;

			} else DevouringFlameTimer -= diff;

			if (SummonAddsTimer <= diff) {
				
				SummonAdds();
				SummonAddsTimer = 45000;
			} else SummonAddsTimer -= diff;			
        }

		//DoMeleeAttackIfReady();
    }

    void SummonAdds() {
        // TODO: Adds will come in waves from mole machines. One mole can spawn a Dark Rune Watcher
        // with 1-2 Guardians, or a lone Sentinel. Up to 4 mole machines can spawn adds at any given time.
        uint8 random = urand(1,4);
        for (uint8 i = 0; i < random; ++i) {
            if (Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 50000.0, true)) {
                float x = std::max(500.0f, std::min(650.0f, pTarget->GetPositionX() + irand(-20,20)));   // Safe range is between 500 and 650
                float y = std::max(-235.0f, std::min(-145.0f, pTarget->GetPositionY() + irand(-20,20))); // Safe range is between -235 and -145
                float z = m_creature->GetBaseMap()->GetHeight(x, y, MAX_HEIGHT);                         // Ground level
                // TODO: Spawn drillers, then spawn adds 5 seconds later
                if (Creature *pAdd = m_creature->SummonCreature(NPC_DARK_RUNE_SENTINEL, x, y, z, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 10000))
                    pAdd->AI()->AttackStart(pTarget);
            }
        }
    }
};

CreatureAI* GetAI_boss_razorscale(Creature* pCreature) {
    return new boss_razorscaleAI (pCreature);
}

/********************
*
*  Expedition Comander
*
*********************/

struct npc_expedition_commanderAI : public ScriptedAI {
	npc_expedition_commanderAI(Creature* pCreature) : ScriptedAI(pCreature) {
		pInstance = pCreature->GetInstanceData();
	}
   
   ScriptedInstance* pInstance;

   uint32 uiTimer;
   uint8   flag2;
   uint64 m_uiCommanderGUID;
   uint8  uiPhase;
   Creature* engineer[2];
   Creature* defender[4];
   Creature* razorscale;

   void Initialize() {
      uiTimer =0;
      uiPhase = 1;
      engineer[0] = 0;
      engineer[1] = 0;
      defender[0] = 0;
      defender[1] = 0;
      defender[2] = 0;
      defender[3] = 0;
   }
   
   std::list<Creature*> GuardList;
   
   void Reset() {
      uiTimer = 0;
   }

   void MovementInform(uint32 uiType, uint32 uiId) {
      if (uiType != POINT_MOTION_TYPE)
         return;
   }

   void UpdateAI(const uint32 uiDiff) {
      ScriptedAI::UpdateAI(uiDiff);
      
      if (uiTimer <= uiDiff) {
         switch(uiPhase) {
            case 1:
               m_creature->SetVisibility(VISIBILITY_OFF);
               uiTimer = 1000;
               uiPhase = 2;
               break;
            case 2:
               engineer[0] = m_creature->SummonCreature(NPC_ENGINEER,591.951477, -95.968292, 391.516998, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 10000);
               engineer[0]->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
               engineer[0]->SetSpeed(MOVE_RUN, 0.5f);
               engineer[0]->GetMotionMaster()->MovePoint(0, Harpoon1);
               engineer[1] = m_creature->SummonCreature(NPC_ENGINEER,591.951477, -95.968292, 391.516998, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 10000);
               engineer[1]->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
               engineer[1]->SetSpeed(MOVE_RUN, 0.5f);
               engineer[1]->GetMotionMaster()->MovePoint(0, Harpoon2);
               uiPhase = 3;
               uiTimer = 7000;
               break;
            case 3:
               uiPhase = 4;
               break;
            case 4:
               defender[0] = m_creature->SummonCreature(NPC_DEFENDER,591.951477, -95.968292, 391.516998, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 10000);
               defender[0] ->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
               defender[0] ->GetMotionMaster()->MovePoint(0, posto1);

               defender[1] = m_creature->SummonCreature(NPC_DEFENDER,591.951477, -95.968292, 391.516998, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 10000);
               defender[1] ->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
               defender[1] ->GetMotionMaster()->MovePoint(0, posto2);

               defender[2] = m_creature->SummonCreature(NPC_DEFENDER,591.951477, -95.968292, 391.516998, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 10000);
               defender[2] ->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
               defender[2] ->GetMotionMaster()->MovePoint(0, posto3);

               defender[3] = m_creature->SummonCreature(NPC_DEFENDER,591.951477, -95.968292, 391.516998, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 10000);
               defender[3] ->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
               defender[3] ->GetMotionMaster()->MovePoint(0, posto4);
               uiPhase = 5;
               break;
            case 5:
               engineer[0]->HandleEmoteCommand(EMOTE_STATE_USESTANDING);
               engineer[1]->HandleEmoteCommand(EMOTE_STATE_USESTANDING);
               defender[0]->HandleEmoteCommand(EMOTE_STATE_READY2H);
               defender[1]->HandleEmoteCommand(EMOTE_STATE_READY2H);
               defender[2]->HandleEmoteCommand(EMOTE_STATE_READY2H);
               defender[3]->HandleEmoteCommand(EMOTE_STATE_READY2H);
               uiTimer = 7000;
               uiPhase = 6;
               break;
            case 6:
				pInstance->SetData(TYPE_RAZORSCALE, IN_PROGRESS);
				if (razorscale = m_creature->SummonCreature (NPC_RAZORSCALE,RazorscaleV,TEMPSUMMON_CORPSE_TIMED_DESPAWN, 999999))
					razorscale->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE);
				uiPhase =7;
				//m_creature->Kill(m_creature, false);
				//m_creature->RemoveCorpse();
				break;
         }
         
         if (!UpdateVictim())
            return;
         DoMeleeAttackIfReady();
      } else uiTimer -= uiDiff;
   }
};


CreatureAI* GetAI_commander_ulduar(Creature* pCreature) {
    return new npc_expedition_commanderAI(pCreature);
}

bool Expedition_commander_ulduar(Player* pPlayer, Creature* pCreature) {

   ScriptedInstance* pInstance = pCreature->GetInstanceData();

    
   if (pInstance && (pInstance->GetData(DATA_VAI) == NOT_STARTED || pInstance->GetData(DATA_VAI) == FAIL)  && pPlayer) {
        pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT,GOSSIP_ITEM_1,GOSSIP_SENDER_MAIN,GOSSIP_ACTION_INFO_DEF);
        pPlayer->SEND_GOSSIP_MENU(13853, pCreature->GetGUID());
   } else
        pPlayer->SEND_GOSSIP_MENU(13910, pCreature->GetGUID());
    return true;
}
bool GossipSelect_commander_ulduar(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction) {
    switch(uiAction) {
        case GOSSIP_ACTION_INFO_DEF:
            if (pPlayer)
                pPlayer->CLOSE_GOSSIP_MENU();

            CAST_AI(npc_expedition_commanderAI, (pCreature->AI()))->uiPhase = 1;
            break;
    }
    return true;
}

/**********************
*
*  Devouring Flame
*
**********************/

struct devouring_flame : public ScriptedAI {

	devouring_flame(Creature *pCreature) : ScriptedAI(pCreature) {
		pInstance = pCreature->GetInstanceData();
	}
	
	ScriptedInstance* pInstance;

	uint32 DevouringFlameTimer;
	
	void EnterCombat(Unit* who) {
		m_creature->CastSpell(m_creature,SPELL_DEVOURINGFLAME2,true);
		m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE);
	}
	
	void Reset() {
		DevouringFlameTimer = 25000;
	}
	
	void UpdateAI(const uint32 diff) {
		m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE);
		if (DevouringFlameTimer <= diff) {
			m_creature->setDeathState(JUST_DIED);
			m_creature->RemoveCorpse();
		} else 
			DevouringFlameTimer -= diff;
	}
};

CreatureAI* GetAI_devouring_flame(Creature* pCreature) {
	return new devouring_flame(pCreature);
}


void AddSC_boss_razorscale()
{
    Script *newscript;
   
   //de los3.diff
	newscript = new Script;
	
	newscript->Name = "npc_expedition_commander_ulduar";
	newscript->GetAI = &GetAI_commander_ulduar;
	newscript->pGossipHello = &Expedition_commander_ulduar;
	newscript->pGossipSelect = &GossipSelect_commander_ulduar;
	newscript->RegisterSelf();
	
	newscript = new Script;
	newscript->Name = "devouring_flame";
	newscript->GetAI = &GetAI_devouring_flame;
	newscript->RegisterSelf();

    newscript = new Script;
    newscript->Name = "boss_razorscale";
    newscript->GetAI = &GetAI_boss_razorscale;
    newscript->RegisterSelf();
}
